package leetcode;

import java.util.Arrays;
import java.util.Comparator;

public class LC2418SortThePeople {


    public String[] sortPeople(String[] names, int[] heights) {
        People[] people = new People[names.length];
        for (int i = 0; i < names.length; i++) {
            people[i] = new People(names[i],heights[i]);
        }
        Arrays.sort(people);
        for (int i = 0; i < people.length; i++) {
            System.out.println(people[i].height);
        }
        String[] ans = new String[names.length];
        for (int i = 0; i < people.length; i++) {
            ans[i] = people[i].name;
        }

        return ans;
    }

//    public static void main(String[] args) {
//        LC2418SortThePeople lc2418SortThePeople = new LC2418SortThePeople();
//        lc2418SortThePeople.sortPeople(new String[]{"111", "222", "wq1"}, new int[]{111, 22, 33});
//    }
}

class People implements Comparable<People> {
    String name;
    int height;
    public People(String name, int height) {
        this.name = name;
        this.height = height;
    }

    @Override
    public int compareTo(People o) { // 根据height逆序排列
        return o.height - this.height;
    }
}